<?
class http
{
	static public function post($site,$page,$data,$port=80,$timeout=5)
	{
		$fp = fsockopen($site, $port, $errno, $errstr, 5);
		
		if (!$fp) 
		{
			return false;		
		}else 
		{
			$Content =array();
			foreach($data as $k=>$v)
			{
				$Content[] = $k."=".rawurlencode ($v);				
			}
			$Content = implode("&",$Content);
			//$stream
			$stream = "POST /$page HTTP/1.1\r\n";
			$stream .= "Content-Type: application/x-www-form-urlencoded\r\n";
			$stream .= "Host: $site\r\n";
			$stream .= "Content-Length: ".strlen($Content)."\r\n";
			$stream .= "Connection: Close\r\n\r\n";
			fwrite($fp, $stream);
			usleep(10);
			fwrite($fp, $Content);
			stream_set_timeout($fp, $timeout);
			$res = stream_get_contents($fp);
			$info = stream_get_meta_data($fp);
			fclose($fp);
			//echo $stream;
			if ($info['timed_out']) 
			{
				return false;    	
			}else 
			{
				//return substr(strstr($res, "\r\n\r\n"),4);
				return true;
			}
		}
	}
}

?>